package com.wisdytech.linkdcs.tool.action;

import com.github.pagehelper.PageInfo;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.StandardTableResult;
import com.wisdytech.common.handler.ResourceMatchingService;
import com.wisdytech.linkdcs.tool.model.ToolRepair;
import com.wisdytech.linkdcs.tool.service.IToolRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhanghailin
 * @since 2018-06-11
 */
@Controller
@RequestMapping("/tool/repairApproval")
public class ToolRepairApprovalAction {

    @Resource
    private IToolRepairService repairService;
    @Autowired
    @Qualifier("resourceMatchingService")
    private ResourceMatchingService resourceMatchingService;
    /**
     * <p>Description: 工装校验</p>
     *
     * @param model model
     * @return String
     */
    @RequestMapping("/index")
    public String toolRepairIndex(Model model, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        return "tool/toolRepairApproval";
    }

    @RequestMapping(value = "/findToolRepairApprovalListByPage/get.mvc")
    @ResponseBody
    public StandardTableResult<ToolRepair> getToolRepairByFilter(String equipCode, String areaId, String shopId, String lineId, String applicationStartDate, String applicationEndDate, Filter filter) {
        PageInfo<ToolRepair> page = repairService.findToolRepairApprovalListByPage(equipCode, areaId, shopId, lineId, applicationStartDate, applicationEndDate, filter);
        return new StandardTableResult<>(page.getTotal(), page.getList());
    }


}
